﻿using System;
//using System.Collections.Generic;
using Petra.Gis.Geometry;


namespace Petra.Gis.RenderingServices.PlanarBase 
{
  /// <summary>
  /// renderer is responsible for rendering (drawing, painting) spatial geometry data
  /// in this Petra.Gis.Geometry format
  /// to specific output format eg. XML, XAML, SVG, SWF,...
  /// renderer must never throws error when incompatible type is given
  /// as it is critical component
  /// </summary>
  public abstract class Renderer //: IRenderer
  {

    protected MapBase _map;
    protected RenderStyle _style;


    /// <summary>
    /// xaml constructor
    /// </summary>
    public Renderer(){ }




    public Renderer(MapBase map, DisplayTransformMatrix transform, RenderStyle style)
    {
      if (map == null || transform == null || style == null)
        throw new ArgumentException("invalid null map or transform or style");

      _map = map;
      _transform = transform;
      _style = style;
    }





    /// <summary>
    /// method that implements drawing (conversion) of gis geometry into output format geometry
    /// </summary>
    /// <param name="geometry"></param>
    public abstract void RenderGeometry(GeometryBase geometry);

    /// <summary>
    /// gives info about current renderer capability of rendering specified geometry
    /// each renderer is specialized to some geometry type
    /// </summary>
    /// <param name="geometry"></param>
    /// <returns>true when given geometry is renderable</returns>
    public abstract bool IsRenderable(GeometryBase geometry);



    ////must implement in inherited
    //protected abstract PlanarMap renderMap { get; set; }

    //public PlanarMap Map
    //{
    //  get { return _map; }
    //  set 
    //  {
    //    if (value == null)
    //      throw new ArgumentException("invalid null map", "map");
    //    _map = value;
    //  }
    //}



    //must implement in inherited
    protected abstract RenderStyle renderStyle { get; set; }


    /// <summary>
    /// set get Renderer display/print style definition
    /// </summary>
    public RenderStyle Style 
    {
      get { return _style; }
      set
      { 
        //todo: style must contain at least few items
        if (value == null)
          throw new ArgumentException("invalid null style", "style");

        _style = value;
      }
    }




    //projection data coordinates in world units to (paper) map units transformation ;-)
    protected DisplayTransformMatrix _transform;

    /// <summary>
    /// returns <c>DisplayTransformMatrix</c> inherited from Map
    /// </summary>
    public DisplayTransformMatrix DisplayTransform
    {
      get { return _transform; }
    }




    protected DomainGeometryType _geometryDomain;

    /// <summary>
    /// get <c>DomainGeometryType</c> enumerator that defines
    /// geometry domain for current renderer instance
    /// </summary>
    public abstract DomainGeometryType RendererGeometryDomain { get; }

  }
}
